package sctu.edu.java.year2016.team01.lishuai.day20160606.chapter12_3;

/**
 * Created by 李大帅 on 2016/6/11.
 * 实现当用户输入姓名和密码时，将每一个姓名和密码加在文件中。。
 */

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.Scanner;
public class Login {

    public void write(String name,int password)
    {
        File file = new File("F:\\java\\hello.txt");
        try {
            Writer out = new FileWriter(file,true);
            String info="姓名："+name+"   密码："+password;
            out.write(info.toCharArray());
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请用户输入姓名和密码：");
        System.out.println("姓名：");
        String name = scan.nextLine();
        System.out.println("密码：");
        int password = scan.nextInt();
        Login login = new Login();
        login.write(name,password);
    }
}

